import * as Apis from "../../apis/Api";
import { observable, action } from 'mobx';
import { Button } from 'antd';
import {WeaTableNew} from 'comsMobx';
const {TableStore} = WeaTableNew;

class ContractPayExceedStore {


    @observable routerParams = {page:'getReportPayExceed'};
    @observable loading = false;
    @observable tableStore = new TableStore();
    @observable requestParams = {};
    @observable names = [];
    @observable contract_counts = [];
    @observable showList = true;

    init = (routerParams) => {
        this.routerParams = routerParams;
    }

    @action
    reLoad = ()=>{
        this.doSearch(this.requestParams);
    }

    @action
    doSearch = (requestParams) => {

        let params = { ...this.routerParams, ...requestParams};
        const yeartype = requestParams.yeartype;
        const myDate = new Date();
        //年份处理
        if (yeartype == "1") {
            params.year = myDate.getFullYear();
        } else if (yeartype == "2") {
            params.year = myDate.getFullYear() - 1;
        } else {

        }

        let years = [`${params.year}`, `${Number(params.year) - 1}`];
        if ("undefined" != typeof (params.year) && "" != params.year) {
            this.loading = true;
            Apis.getReportInfo(params).then(data => {
                // this.loading = false;
                // const sessionkey = data.datas.sessionkey;
                // this.tableStore.getDatas(sessionkey);

                this.mathChart(data.datas.sumgroup);
                this.requestParams = params;
                this.tableStore.getDatas(data.datas.sessionkey);
                this.loading = false;
            });
        }

    }

    @action
    mathChart = (sumgroup)=>{
        let names = ['逾期一周','逾期一个月','逾期超过一个月'];
        let contract_counts = [sumgroup.weekCount,sumgroup.monthCount,sumgroup.overMonthCount];

        this.names = names;
        this.contract_counts = contract_counts;
    }
   
    @action
    changeShowList = (bl) => {
        this.showList = (!bl);
    }
}

export default ContractPayExceedStore;